﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LituoPro.ltcore
{
    public class DataVerify
    {

        public bool verify(Byte[] bytes,int verifyByteIndex, int endIndex)
        {
            byte checkByte = bytes[verifyByteIndex];
            if (bytes.Length <= verifyByteIndex) 
            { 
                return false;
            }
            byte sum = 0;
            for (int i = 0; i <= endIndex; i++)
            {
                sum += bytes[i];
            }
            if (checkByte == sum)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public byte getVerify(Byte[] bytes)
        {
            byte sum = 0;
            for (int i = 0; i < bytes.Length; i++)
            {
                sum += bytes[i];
            }
            return sum;
        }
    }
}
